package mume.android;

import android.app.TabActivity;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;

public class CaptureWindow implements OnClickListener{
	public CaptureWindow(Context context)
	{
		this.context = context;

		//alle objecten aanmaken
		iView = (ImageView) ((TabActivity)context).findViewById(R.id.cameraview);
		iButton = (ImageButton) ((TabActivity)context).findViewById(R.id.capturebutton);
		iButton.setOnClickListener(this);
		
		setChoiceMode();
	}
	
	public int getImage() {
		return image;
	}

	@Override
	public void onClick(View v) 
	{
		if( isChoiceMode )
			setCaptureMode();
		else
			setChoiceMode();
	}
	
	private void setCaptureMode()
	{
		isChoiceMode = false;
		
		//button veranderen
		iButton.setImageDrawable(context.getResources().getDrawable(R.drawable.button_new));
		
		//imageview aanpassen
		iView.setImageDrawable(context.getResources().getDrawable(image));
		iView.setVisibility(android.view.View.VISIBLE);
		
		//verdergaan met barcode
		((MainActivity)context).useBarcode();
	}
	
	private void setChoiceMode()
	{
		isChoiceMode = true;
		
		//button veranderen
		iButton.setImageDrawable(context.getResources().getDrawable(R.drawable.button_capture));
		
		//imageview aanpassen
		iView.setVisibility(android.view.View.INVISIBLE);	//image invisible maken
	
	}
	
	private boolean isChoiceMode = false;
	private int image = R.drawable.usedimage;
	private Context context;
	
	private ImageView iView;
	private ImageButton iButton;
}
